#include "pwddialog.h"
#include "ui_pwddialog.h"
#include "QDebug"

pwddialog::pwddialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::pwddialog)
{
    ui->setupUi(this);
    ui->lbl_error->setText("");
    this->setWindowTitle("Password Entry");
    this->setMaximumSize(this->width(),this->height());
}

pwddialog::~pwddialog()
{
    delete ui;
}

QString pwddialog::getPassword()
{
    return password_;
}

void pwddialog::on_pb_done_clicked()
{
    password_ = ui->le_pwdfield->text();

    qDebug()<<"Lemgth of pawd is "<<password_.length();

    if(password_.length() < 12){
        password_ = "";
        ui->lbl_error->setText("Error: Password must contain atleast 12 characters");
    }
    else
    {
        this->close();
    }
}

void pwddialog::reject()
{
    qDebug()<<Q_FUNC_INFO;

    this->accept();
//    if(password_.length() < 12){
//        password_ = "";
//        ui->lbl_error->setText("Error: Password not set, as password must contain atleast 12 characters");
//    }
//    else
//    {
//        this->accept();
//    }

}
